package com.shsc.example.project;

import static com.shsc.example.project.MainActivity.RECEIVE_FLAG;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class SendBrodcastRecevieAct extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_send_brodcast);

        Button btSendBrodcast = (Button) findViewById(R.id.bt_send_brodcast);
        EditText etInput = (EditText) findViewById(R.id.et_input);

        btSendBrodcast.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(RECEIVE_FLAG);
                intent.putExtra("name", etInput.getText().toString());         //向广播接收器传递数据
                sendBroadcast(intent);
            }
        });
    }
}